﻿$(function () {
    $("#PopupContent").dialog({
        autoOpen: false,
        resizable: false,
        height: 500,
        width: 600,
        modal: true,
        hide: "fade",
        show: "fade",
        //Scrollbar fix
        open: function (event, ui) { $('body').css('overflow', 'hidden'); $('.ui-widget-overlay').css('width', '100%'); },
        close: function (event, ui) {
            $('body').css('overflow', 'auto');
        }
    });

    $("#Delete").live("click", function () {
        $("#List").mask();
        $.ajax(
        {
            url: $Url.resolve("~/Customer/Delete"),
            data: { id: deletingCustomerID },
            type: "POST",
            dataType: "json",
            cache: false,
            success: function (result) {
                $("#List").unmask();
                closePopUp();
                if (result.Success) {
                    ShowList();
                }
                else {
                    $("#ErrorDialogMessage").html(result.Message);
                    $("#ErrorDialog").dialog("open");
                }
            },
            error: function (xhr, text, err) {
                handleGlobalError(xhr, text, err);
            }
        }
        );
    });

    $("#ErrorDialog").dialog({
        autoOpen: false,
        resizable: false,
        height: 200,
        modal: true,
        buttons: {
            OK: function () {
                $("#ErrorDialog").dialog("close");
            }
        },
        //Scrollbar fix
        open: function (event, ui) { $('body').css('overflow', 'hidden'); $('.ui-widget-overlay').css('width', '100%'); },
        close: function (event, ui) { $('body').css('overflow', 'auto'); }
    });

    initFilter();
    initList();
});